# Maintainer: Alexander F Rødseth <xyproto@archlinux.org>
# Contributor: Arch Haskell Team <arch-haskell@haskell.org>

pkgname=haskell-ghc-paths
pkgver=0.1.0.12
pkgrel=12
pkgdesc="Knowledge of GHC's installation directories"
url='https://hackage.haskell.org/package/ghc-paths'
license=('BSD')
arch=('loong64' 'x86_64')
depends=('ghc-libs')
makedepends=('ghc')
source=("https://hackage.haskell.org/packages/archive/ghc-paths/$pkgver/ghc-paths-$pkgver.tar.gz")
sha512sums=('1c66caf459f5783bde38a47ce1292bf5c47fef21e3f69d7f6c052b4eb39f446ed5decd38f0e4143a90d55ba44ebc0891b4497050cc652cbf3fcad636d45690e9')

build() {
    cd "${srcdir}/ghc-paths-${pkgver}"
    
    runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
        --prefix=/usr --docdir=/usr/share/doc/$pkgname \
        --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm
    runhaskell Setup build $MAKEFLAGS
    runhaskell Setup register --gen-script
    runhaskell Setup unregister --gen-script
    sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
    sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

package() {
    cd "${srcdir}/ghc-paths-${pkgver}"
    
    install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
    install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
    runhaskell Setup copy --destdir="$pkgdir"
    install -D -m644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
    rm -f "$pkgdir"/usr/share/doc/$pkgname/LICENSE
}
